-- author: Tukz

addonName, ns = ...
local media = "Interface\\Addons\\"..addonName.."\\media\\"

UNIT_NAME_FONT     = media.."font.ttf"
NAMEPLATE_FONT     = media.."font.ttf"
DAMAGE_TEXT_FONT   = media.."combat.ttf"
STANDARD_TEXT_FONT = media.."font.ttf"


local module = {}
module.name = "Font"
module.Init = function()
   if not SCDB.modules[module.name] then return end
   if SCDB[module.name] == nil then SCDB[module.name] = {} end

   
	local eventframe = CreateFrame("Frame", nil, UIParent)
		
	local SetFont = function(obj, font, size, style)
		obj:SetFont(font, size, style)
		if style then
			obj:SetShadowOffset(0,0)
		else
			obj:SetShadowOffset(1,-1)
		end
	end

	eventframe:RegisterEvent("PLAYER_ENTERING_WORLD")
	eventframe:SetScript("OnEvent", function(self, event, addon)
		
		local NORMAL     = SCDB["Main"].Font or STANDARD_TEXT_FONT
		local COMBAT     = SCDB["Main"].Font or STANDARD_TEXT_FONT
		local NUMBER     = SCDB["Main"].Font or STANDARD_TEXT_FONT
		local fSize      = 13

		UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT = 12
		CHAT_FONT_HEIGHTS = {12, 13, 14, 15, 16, 17, 18, 19, 20}

		-- Base fonts
		SetFont(GameFontNormalSmall,                NORMAL, fSize, "THINOUTLINE")
		SetFont(GameFontHighlight,                  NORMAL, fSize, "THINOUTLINE")
		SetFont(GameTooltipHeader,                  NORMAL, fSize)
		SetFont(NumberFont_OutlineThick_Mono_Small, NUMBER, fSize, "THINOUTLINE")
		SetFont(NumberFont_Outline_Huge,            NUMBER, 28, "THINOUTLINE")
		SetFont(NumberFont_Outline_Large,           NUMBER, fSize+3, "THINOUTLINE")
		SetFont(NumberFont_Outline_Med,             NUMBER, fSize+1, "THINOUTLINE")
		SetFont(NumberFont_Shadow_Med,              NORMAL, fSize)
		SetFont(NumberFont_Shadow_Small,            NORMAL, fSize)
		SetFont(QuestFont,                          NORMAL, fSize+2)
		SetFont(QuestFont_Large,                    NORMAL, fSize+2)
		SetFont(SystemFont_Large,                   NORMAL, fSize+2)
		SetFont(SystemFont_Med1,                    NORMAL, fSize-1)
		SetFont(SystemFont_Med3,                    NORMAL, fSize-1)
		SetFont(SystemFont_OutlineThick_Huge2,      NORMAL, fSize+7, "THINOUTLINE")
		SetFont(SystemFont_Outline_Small,           NUMBER, fSize+2, "THINOUTLINE")
		SetFont(SystemFont_Shadow_Large,            NORMAL, fSize+2)
		SetFont(SystemFont_Shadow_Med1,             NORMAL, fSize)
		SetFont(SystemFont_Shadow_Med3,             NORMAL, fSize)
		SetFont(SystemFont_Shadow_Outline_Huge2,    NORMAL, fSize+7, "THINOUTLINE")
		SetFont(SystemFont_Shadow_Small,            NORMAL, fSize)
		SetFont(SystemFont_Small,                   NORMAL, fSize)
		SetFont(SystemFont_Tiny,                    NORMAL, fSize)
		SetFont(Tooltip_Med,                        NORMAL, fSize)
		SetFont(Tooltip_Small,                      NORMAL, fSize)
		SetFont(CombatTextFont,                     COMBAT, 100, "THINOUTLINE") -- number here just increase the font quality.
		SetFont(SystemFont_Shadow_Huge1,            NORMAL, 20, "THINOUTLINE")
		SetFont(ZoneTextString,                     NORMAL, 32, "THINOUTLINE")
		SetFont(SubZoneTextString,                  NORMAL, 25, "THINOUTLINE")
		SetFont(PVPInfoTextString,                  NORMAL, 22, "THINOUTLINE")
		SetFont(PVPArenaTextString,                 NORMAL, 22, "THINOUTLINE")
		
		SetFont = nil
		self:SetScript("OnEvent", nil)
		self:UnregisterAllEvents()
		self = nil
	end)
	
end
tinsert(SuperClassic.modules, module) -- finish him!	